const Controller = require('egg').Controller;

class OperationLogController extends Controller {
  async list(){
    const ctx = this.ctx;
    const query = ctx.query;
    let params = {
      pageSize: +query.pageSize || this.app.config.pageBean.pageSize,
      pageNo: +query.pageNo || 1,
    }


    let where = {
      type: query.type,
      target_type: query.targetType,
      target_id: query.targetId
    };
    const data = await this.service.operationLog.list(
      params.pageNo,
      params.pageSize,
      where
    );
    params.totalSize = data.count;
    params.totalPage = data.count == 0 ? 1 : Math.ceil(data.count / params.pageSize);
    ctx.locals = {
      params: params,
      list: data.rows,
    }
    // ctx.body = data;
    await ctx.render('admin/operationLog/list.html');
  }

  

}

module.exports = OperationLogController;